import SocketsXinghuo from "./chatxinghuo";
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: "35df018f-bb4b-48d0-9c99-2b2818f89db1",
  baseURL: 'https://ark.cn-beijing.volces.com/api/v3',
});
const xinghuo = new SocketsXinghuo();
export const sendAiMessages = (str: string): Promise<string> => {
  return new Promise(async (resolve, reject) => {
    console.log(xinghuo)
    xinghuo
      .send(str)
      .then((text) => {
        resolve(text);
      })
      .catch((err) => {
        console.log(err)
        reject()
      })
      .finally(() => { });
  });
};
export const sendAiMessage = (str: string): Promise<string> => {
  return new Promise(async (resolve, reject) => {
    const completion = await openai.chat.completions.create({
      messages: [{ role: "system", content: str }],
      model: 'deepseek-r1-250528',
    });
    console.log('啊哈哈哈')
    console.log(completion)
    const text = completion.choices[0].message.content;
    console.log(text)
    resolve(text);

  });
};
